home *** CD-ROM | disk | FTP | other *** search
/ PsL Monthly 1993 December / PSL Monthly Shareware CD-ROM (December 1993).iso / prgmming / dos / c / ww_tv.exe / TEDITOR3.CPP < prev    next >
C/C++ Source or Header  |  1991-11-22  |  5KB  |  130 lines

  1. /****************************************************************************/
  2. /*                                                                          */
  3. /*                    Copyright (c) 1991 Primatech Inc.                     */
  4. /*                                                                          */
  5. /*                           All Rights Reserved                            */
  6. /*                                                                          */
  7. /****************************************************************************/
  8.  
  9.  
  10.  
  11. // $config$=/MTEditor3.cpp
  12. //
  13. //  $NAME$:
  14. //          ..Module Overview
  15. //
  16. //  $GLOBAL PATHS$
  17. //          modules\all\TEditor3.cpp
  18. //          modules\c++\TEditor3.cpp
  19. //          objects\TEditor
  20. //
  21. //  $0$
  22. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  23. //
  24. //  Purpose:    Additional function for the TurboVision TEditor class.
  25. //
  26. //  Prototypes location:    $/SEE(Editors.h)$
  27. //
  28. //  Other Information:
  29. //
  30. //  See also:       $/SEE()$
  31. //
  32. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  33.  
  34.  
  35. //$-1$
  36. #if 0
  37. //$1$
  38. /**** MODIFICATIONS HISTORY ****/
  39.  
  40. Created:        08 November 1991 by John L. Swartzentruber
  41.  
  42.  
  43. $SKIP START$
  44. #endif
  45.  
  46. /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
  47. /*+                                                                        +*/
  48. /*+                       I N C L U D E   F I L E S                        +*/
  49. /*+                                                                        +*/
  50. /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
  51. #define Uses_TEditor
  52. #include <tv.h>
  53.  
  54.  
  55. //$SKIP END$
  56. //$2$
  57. /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
  58. /*+                                                                        +*/
  59. /*+       # D E F I N E S    C L A S S E S   and    T Y P E D E F S        +*/
  60. /*+                                                                        +*/
  61. /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
  62.  
  63.  
  64.  
  65. //$3$
  66. /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
  67. /*+                                                                        +*/
  68. /*+                E X T E R N A L    D E F I N I T I O N S                +*/
  69. /*+                                                                        +*/
  70. /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
  71.  
  72.  
  73. //$4$
  74. /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
  75. /*+                                                                        +*/
  76. /*+                  S T A T I C    D E F I N I T I O N S                  +*/
  77. /*+                                                                        +*/
  78. /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
  79.  
  80.  
  81.  
  82. //$END$
  83. /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
  84. /*+                                                                        +*/
  85. /*+          S T A T I C   F U N C T I O N   P R O T O T Y P E S           +*/
  86. /*+                                                                        +*/
  87. /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
  88.  
  89.  
  90.  
  91. /* EJECT */
  92. //****************************************************************************
  93. //
  94. //      Function $NAME$:
  95. //                          TEditor::normalizeBuffer(ushort)
  96. //                                                                            $1$
  97. // 
  98. //      Purpose:    To reset the "gapLen" and "bufSize" attributes.  If
  99. //                  necessary, data is moved to accomodate this.  The actual
  100. //                  size of the buffer is unchanged.  Before calling this
  101. //                  function, the buffer must be at least max(newSize,bufSize)
  102. //                  bytes long.
  103. //
  104. //      Return:     True on success, False on failure
  105. //
  106. //      Other information:
  107. //
  108. //          This function should only be called by a setBufSize() function.
  109. //
  110. //$0$
  111. //****************************************************************************
  112. Boolean TEditor::normalizeBuffer(ushort newSize)
  113. //                                                                            $END$
  114. {
  115.     ushort moveLen = bufSize - curPtr - gapLen + delCount;
  116.     ushort dest = newSize - moveLen;
  117.     ushort source = bufSize - moveLen;
  118.  
  119.     if (dest >= curPtr) {
  120.         memmove(buffer + dest, buffer + source, moveLen);
  121.  
  122.         bufSize = newSize;
  123.         gapLen = bufSize - bufLen;
  124.  
  125.         return True;
  126.     }
  127.  
  128.     return False;
  129. }
  130.